<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>jQuery History Plugin Ajax Sample</title>
</head>
<body>
  <h1>jQuery History Plugin MVC Sample</h1>
  <div class="container">
    <ul class="ajax-links">
      <li><a href="#139mail" class="default-content">邮箱l</a></li>
      <li><a href="#life">12580</a></li>
      <li><a href="#balance">余额</a></li>
    </ul>
	<div id="loading">loading...</div>
	<div id="c_content"></div>

  </div>
  <hr />



<script type="text/javascript" src="js/jquery.js?v=1.5.2"></script>
<script type="text/javascript" src="js/jquery.history.js?v=1.0"></script>
<script type="text/javascript" src="js/jquery.jtemplates.js?v=0.7.8"></script>
<script>

(function($){
    var origContent = "";

    function loadContent(hash) {
        if(hash != ""){
			origContent = hash;
        }else{
			origContent = '139mail';
		} 

		$("#loading").show();

		$.ajax({
			type:       "POST",
			dataType:   "json",
			url: "json/"+origContent+".json",
			success:    function(data){
				if( origContent.indexOf("2a") > -1 ){
					$('#content_2b').setTemplateURL("tpl/"+origContent+".html?date="+new Date().getTime(), null, {filter_data: true});
					$('#content_2b').processTemplate(data); 
				}else{
					$('#c_content').setTemplateURL("tpl/"+origContent+".html?date="+new Date().getTime(), null, {filter_data: true});
					$('#c_content').processTemplate(data); 
				}
			},
			error:function(e){
				alert("错误"+e);
			},
			complete:function(){
				$("#loading").hide();
			}
		});

    }

    $(document).ready(function() {

            $.history.init(loadContent);

            $('.ajax-links2 a').live("click",function(e) {
				var url = $(this).attr('href');
				url = url.replace(/^.*#/, '');
				$.history.load( url );
				return false;
            });
   });

})(jQuery);

</script>

</body>
</html>
